Skip to content

Conversation

@nojnhuh
Copy link
Contributor

@nojnhuh nojnhuh commented Mar 27, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

Because agent pool definitions are required by the AKS API when a managed cluster is created, CAPZ aggregates ManagedClustersAgentPools and converts them to ManagedClusterAgentPoolProfiles. This conversion must contain no loss in fidelity in order for the agent pools defined in the managed cluster creation to match the agent pools defined by AzureManagedMachinePools and AzureASOManagedMachinePools. If there are differences, those will be reconciled after the ASO ManagedCluster is reconciled when the standalone ASO ManagedClustersAgentPools are reconciled, but that update will fail if any of the differing fields are immutable.

I also added a linter check to enforce this going forward.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests
  • cherry-pick candidate

Release note:

Fixed a bug causing an unnecessary update to an AKS agent pool after its managed cluster is created when certain fields are defined.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Mar 27, 2025
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 27, 2025
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 27, 2025
}
if properties.KubeletConfig != nil {
agentPool.KubeletConfig = properties.KubeletConfig
AvailabilityZones: properties.AvailabilityZones,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the new fields here aren't possible to set from an AzureManagedMachinePool, so there's a fair bit of no-op here. I was too lazy to audit which ones can actually be set, but keeping everything here makes for one less thing to worry about in case we do add or remove any features from CAPZ.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, thx for adding the maintenance comments so we're less likely to omit this in the future

ScaleDownMode: hubPool.Spec.ScaleDownMode,
ScaleSetEvictionPolicy: hubPool.Spec.ScaleSetEvictionPolicy,
ScaleSetPriority: hubPool.Spec.ScaleSetPriority,
SecurityProfile: hubPool.Spec.SecurityProfile,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main alternative to this approach is to use unkeyed struct fields and let the compiler check that everything is defined, but I think I prefer the sanity check of having both field names on one line like this.

@codecov
Copy link

codecov bot commented Mar 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.61%. Comparing base (8bd1865) to head (6080b8a).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5521      +/-   ##
==========================================
+ Coverage   52.57%   52.61%   +0.04%     
==========================================
  Files         272      272              
  Lines       29470    29485      +15     
==========================================
+ Hits        15493    15513      +20     
+ Misses      13169    13165       -4     
+ Partials      808      807       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nojnhuh nojnhuh moved this from Todo to Needs Review in CAPZ Planning Mar 27, 2025
@nojnhuh
Copy link
Contributor Author

nojnhuh commented Mar 27, 2025

/cherry-pick release-1.19

This probably doesn't affect release-1.18

@k8s-infra-cherrypick-robot

@nojnhuh: once the present PR merges, I will cherry-pick it on top of release-1.19 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.19

This probably doesn't affect release-1.18

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@nawazkh
Copy link
Member

nawazkh commented Mar 28, 2025

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 28, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 13cc4df2543b1fe444eaf04662db7393dbd809ba

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nawazkh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 28, 2025
@k8s-ci-robot k8s-ci-robot merged commit 1c6a5d3 into kubernetes-sigs:main Mar 28, 2025
22 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Mar 28, 2025
@github-project-automation github-project-automation bot moved this from Needs Review to Done in CAPZ Planning Mar 28, 2025
@k8s-infra-cherrypick-robot

@nojnhuh: new pull request created: #5524

In response to this:

/cherry-pick release-1.19

This probably doesn't affect release-1.18

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants